#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll T,m,n,L,V,p[N],ans=1,cnt;
struct node{
    ll d,v,a,l=0,r=0;
}cr[N];
void init()
{
    ans=1;cnt=0;
    for(int i=1;i<=n;i++)cr[i].l=cr[i].r=0;
}
bool cmp(node x,node y)
{
    if(x.l!=y.l)return x.l<y.l;
    return x.r<y.r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--)
    {
        init();
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
            cin>>cr[i].d>>cr[i].v>>cr[i].a;
        for(int i=1;i<=m;i++)
            cin>>p[i];
        for(int i=1;i<=n;i++)
        {
            if(cr[i].a==0&&cr[i].v>V){
                int t=lower_bound(p+1,p+m+1,cr[i].d)-p;
                cr[i].l=t;cr[i].r=m;
            }
            else if(cr[i].a<0&&cr[i].v>V)
            {
                ll temp=ceil(abs(1ll*V*V-cr[i].v*cr[i].v)*1.0/(1.0*abs(2*cr[i].a)));
                if(temp+cr[i].d>L)cr[i].r=m;
                else{
                    int t=lower_bound(p+1,p+m+1,temp+cr[i].d)-p;
                    cr[i].r=t-1;
                }
                cr[i].l=lower_bound(p+1,p+m+1,cr[i].d)-p;
            }
            else if(cr[i].a>0)
            {
                if(cr[i].v>V)
                {
                    cr[i].l=lower_bound(p+1,p+m+1,cr[i].d)-p;
                    cr[i].r=m;
                }
                else{
                    ll temp=floor((1ll*V*V-cr[i].v*cr[i].v)*1.0/(2.0*cr[i].a));
                    if(cr[i].d+temp>=L)cr[i].l=cr[i].r=0;
                    else{
                        cr[i].l=upper_bound(p+1,p+m+1,cr[i].d+temp)-p;
                        cr[i].r=m;
                    }
                }
            }
            if(cr[i].r<cr[i].l)cr[i].l=cr[i].r=0;
            if(cr[i].l!=0&&cr[i].r!=0)cnt++;
        }
        cout<<cnt<<" ";
        if(cnt==0){
            cout<<m<<'\n';
            continue;
        }
        sort(cr+1,cr+1+n,cmp);
        int tl=1,tr=m;;
        for(int i=1;i<=n;i++)
        {
            if(cr[i].l==0&&cr[i].r==0)continue;
            if(tr<cr[i].l){
                ans++;
                tl=cr[i].l;tr=cr[i].r;
            }
            else{
                tl=cr[i].l;
                tr=tr>cr[i].r?cr[i].r:tr;
            }
        }
        cout<<m-ans<<'\n';
    }
    return 0;
}
